// 区间修改区间查询

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N = 1e5 + 10;
int n, m;
int a[N];
int lowbit(int x) { return x & -x; }
struct {
  ll t[N];
  void add(int x, int k) {
    for (int i = x; i <= n; i += lowbit(i)) t[i] += k;
  }
  ll query(int x) {
    ll sum = 0;
    for (int i = x; i; i -= lowbit(i)) sum += t[i];
    return sum;
  }
} tr, tri;
// tr[]数组是原始数组的差分数组d[i]的树状数组
// tri[]数组是原始数组的差分数组乘以i即i*d[i]的树状数组

ll getsum(int x) { return tr.query(x) * (x + 1) - tri.query(x); }
int main() {
  cin >> n >> m;
  for (int i = 1; i <= n; ++i) cin >> a[i];
  for (int i = 1; i <= n; ++i)
    tr.t[i] = a[i] - a[i - 1], tri.t[i] = tr.t[i] * i;
  for (int x = 1; x <= n; ++x)
    for (int i = x - 1; i >= x - lowbit(x) + 1; i -= lowbit(i)) {
      tr.t[x] += tr.t[i];
      tri.t[x] += tri.t[i];
    }
  while (m--) {
    char op;
    cin >> op;
    if (op == 'Q') {
      int l, r;
      cin >> l >> r;
      cout << getsum(r) - getsum(l - 1) << '\n';
    } else {
      int l, r, c;
      cin >> l >> r >> c;
      tr.add(l, c);
      tr.add(r + 1, -c);
      tri.add(l, l * c);
      tri.add(r + 1, (r + 1) * -c);
    }
  }
}
